Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute_hook: Improve logging #1512

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clayne
Copy link

@clayne clayne commented Jul 25, 2019

  • Provide per-hook entry and exit logging around each hook called.
    This came out of a debugging experience where client code was
    adding the same hook twice at different stages of execution but it
    wasn't immediately apparent from debugging output to even look in
    that direction.

Example output:

core @2019-07-25 17:04:06> Entering hook core.app.before_request [CODE(0x55f96d8dbac0)] in (eval 221) l. 1
core @2019-07-25 17:04:06> Exited hook core.app.before_request [CODE(0x55f96d8dbac0)] in (eval 221) l. 1

@tomhukins
Copy link
Contributor

Having information such as CODE(0x55f96d8dbac0) in log files seems unhelpful to me. Why do you consider this change an improvement?

@clayne
Copy link
Author

clayne commented Sep 9, 2019

Having information such as CODE(0x55f96d8dbac0) in log files seems unhelpful to me. Why do you consider this change an improvement?

Because that's the only pragmatically "id" we have accessible to us to even determine what code ref is being executed at the time without making more extensive changes to all the hook code to store some kind of surrogate id or Carp style line origination data (which is significantly more work and probably overkill). I do agree the implicit stringification part is a bit of a hack though.

Additionally, this is only logged at the core debugging level, so it's not exactly something that's even going to be present in the normal case. If you have better ideas, I'm all ears, but what I do know is that the current code completely masks logging for multiple hooks registered for the same hook type.

* Provide *per*-hook entry and exit logging around each hook called.
  This came out of a debugging experience where client code was
  adding the same hook twice at different stages of execution but it
  wasn't immediately apparent from debugging output to even look in
  that direction.

Example output:

core @2019-07-25 17:04:06> Entering hook core.app.before_request [CODE(0x55f96d8dbac0)] in (eval 221) l. 1
core @2019-07-25 17:04:06> Exited hook core.app.before_request [CODE(0x55f96d8dbac0)] in (eval 221) l. 1
@cromedome
Copy link
Contributor

@tomhukins, @clayne - I see your respective points.

@clayne if you can provide a minimal test case or example wrapped up in a .t file, I can spend a little time noodling on this to see if I can come up with a solution that works for everyone.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants